package sliver.dao.impl;

import java.io.Serializable;
import java.util.List;

import org.springframework.stereotype.Repository;

import sliver.dao.ShopVipDao;
import sliver.entity.ShopVip;

@Repository
public class ShopVipDaoImpl extends BaseDaoImpl<ShopVip> implements ShopVipDao{

	@Override
	public List<ShopVip> findList(Serializable shopperId) {
		
		String queryString = "SELECT svip FROM ShopVip svip WHERE svip.vip.shopper.id = ?";
		
		return complexQuery(queryString, new Object[]{shopperId});
	}
	
	@Override
	public ShopVip findShopVip(Serializable shopperId, Serializable customId) {
		
		String queryString = "SELECT svip FROM ShopVip svip WHERE svip.custom.id = ? AND svip.vip.shopper.id = ?";
		
		List<ShopVip> vips = complexQuery(queryString, new Object[]{customId, shopperId});
		
		System.out.println(vips.size());
		
		if(vips != null && vips.size() == 1)
			return vips.get(0);
		
		return null;
	}
}
